<html>
 <head> 
  <meta charset="utf-8" /> 
  <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" /> 
  <meta name="format-detection" content="telephone=no" /> 
  <meta name="msapplication-tap-highlight" content="no" /> 
  <title>{$room.roomid}号金花房间</title> 
  <link rel="stylesheet" type="text/css" href="/app/css/flower-2.0.3.css" /> 
  <link rel="stylesheet" type="text/css" href="/app/css/common/alert-1.1.css">
  <link rel="stylesheet" type="text/css" href="/app/css/zjh.css" /> 
<link rel="stylesheet" href="/app/css/app.css" /> 
  <style>
  .mainPart{
    position: relative;
    height: auto;
  }
  .alert .mainPart .id{
    position: relative;
  }
.alert .mainPart .alertText{
  position: relative;
}

.alert .mainPart{
  height: auto;
}
.message .textPart{
   height: 40vh !important;
   overflow-y: auto !important;
  }
.member1 .avatar div{
      line-height: 52px !important;
}
 .lishijilu{
         position: relative;background:url(http://goss.fexteam.com/files/images/common/alert3.png) 0% 0% / 100% 100% no-repeat;width: 82%;margin-left: 3.5vh;color: black;/* margin: auto; */margin-top: 2vh;height: 9vh;line-height: 4vh;font-size: 15px;border-radius: 6px;padding-left: 10px;padding-top: 1vh;
    }
}
}
@media screen and (max-width: 320px) {
    .lishijilu{
         position: relative;background: #a2befc;width: 82%;margin-left: 3.5vh;color: black;/* margin: auto; */margin-top: 2vh;height: 9vh;line-height: 4vh;font-size: 12px;border-radius: 6px;padding-left: 10px;padding-top: 1vh;
    }

}

</style>

  <script src="/app/js/homepage/jq.js" type="text/javascript"></script> 
  <script src="/app/js/homepage/home.js" type="text/javascript"></script> 
  <script src="/app/js/app.js" type="text/javascript"></script>
  <script src="/app/js/game5.js" type="text/javascript"></script> 
  <script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js" type="text/javascript"></script>

  <script>
  var url =window.location.href;//用户要分享的网址
  var title  = '熟人炸金花(房间号:{$room.roomid})';//分享的标题
  var shareimg = 'http://'+window.location.hostname+'/app/home2.jpg';//分享的图片
  var desc = '<if condition="$room['gz2']">牌型： <foreach name="room['gz2']" item="one">{$one}</foreach> </if> <if condition="$room['cm']">筹码:{$room['cm']}</if><if condition="$room['sx']">上限:{$room['sx']}</if> ';//分享的描述信息
  WeChat(url,title,shareimg,desc);
</script>

 </head> 
 <body> 
     <img src="/app/bg1.png" style="display: none">
    <img src="/app/dyj.png" style="display: none">

     <div id="overtime" style="display: none">
    <canvas id="myCanvas" width="800" height="1297" style="display: none"></canvas>
    </div>


<if condition="$room['endtime'] gt 0">
   <php>
      $mapxx=array();
      $mapxx['uid']=$user['id'];
      $mapxx['room']=$room['id'];

      if(M('user_room')->where($mapxx)->find()){
  </php>
    <script type="text/javascript">
        var data={};
        data.id={$room['roomid']};
        data.zjs={$room['zjs']};
        data.time='{$room['time']|date="Y-m-d H:i:s",###}';
        data.user={$room['overxx']};
        <php>
              $overxx=json_decode($room['overxx'],true);
              foreach($overxx as $key=>$value){
                    $nickname=usernickname($value[id]);
                    echo 'data.user["'.$key.'"]["nickname"]="'.$nickname.'";';
              }

        </php>
        overroom(data);
    </script>

   <php>
     }
     else{
  </php>
  <script type="text/javascript">
    document.title = '温馨提示';
  </script>
  <div id="valert2" class="alert">
   <div class="alertBack" style="opacity: 1;"></div> 
   <div class="mainPart" style="height: 27%;margin-top: -113.39px;">
    <div class="backImg">
     <div class="blackImg" style="height: 82%;"></div>
    </div> 
    <div class="alertText" style="top: 45%;" id="tipmsg">房间已经关闭</div> 
     
     
   </div>
  </div>
  <php>
      }
      exit();
  </php>
</if>


<if condition="$fzuser['sfgl']  && (!$mayuser[$user['id']])">
    <script type="text/javascript">
    document.title = '温馨提示';
  </script>
<div id="valert2" class="alert">
   <div class="alertBack" style="opacity: 1;"></div> 
   <div class="mainPart" style="height: 27%;margin-top: -113.39px;">
    <div class="backImg">
     <div class="blackImg" style="height: 82%;"></div>
    </div> 
    <div class="alertText" style="top: 45%;" id="tipmsg">无法加入，请联系管理员。</div> 
     
     
   </div>
  </div>

  <php>
      exit();
  </php>
</if>

  <div class="roomCard">
   <img src="/app/img/roomCard.png" /> 
   <div class="num">
    <div style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: rgb(255, 255, 255); opacity: 0.2; border-radius: 10px;"></div> 
    <div style="position: relative; padding: 0px 10px 0px 35px;" id="fknum">
     {$user['fk']}张
    </div>
   </div>
  </div> 
  <div class="round" id="jsxx">
     {$room.js}&nbsp;/&nbsp;{$room.zjs}局
  </div> 
  <img src="/app/img/home.png" class="return" style="right: 10px;" onclick="opnemm('fangjian_fanhuisy','tishi')" /> 
  <img src="/app/img/note4.png" class="return" style="right: 60px;" onclick="opnemm('fangjian_tishi','tishi')"/> 
  <img src="/app/img/footer_bull.png" usemap="#planetmap" class="bottom" /> 
  <img src="/app/img/icon_game_rule.png" class="bottomGameRule" style="z-index: 110;" onclick="opnemm('fangjian_gz','vroomRule')"/> 
  <img src="/app/img/icon_sound61.png" class="bottomGameHistory" style="z-index: 110;"onclick="opnemm('fangjian_yinyue','vaudioRoom')" /> 
  <img src="/app/img/icon_game_message.png" class="bottomGameMessage" onclick="opnemm('fangjian_kj','message')"/> 

  <div id="messageSay">
</div>

<div class="playerPK" style="display: none;">
   <div class="pkBack"></div> 
   <div class="pk1" style="left: 0px;">
    <img src="/app/img/comLeft.png" style="position: absolute; top: 0px; left: 0px; width: 95%; height: 140px;" /> 
    <div class="pkPlayer">
     <img src="/app/img/player.png" class="background" style="display: none;" /> 
     <div class="title">
      --
     </div> 
     <img src="" class="avatar" /> 
     <div class="score">--
     </div> 
     <div class="quitBack" style="display: block;"></div>
    </div> 
    <img src="/app/img/comLoser.png" class="pkLoser" style="display: none;" />
   </div> 
   <div class="pk2" style="right: 0px;">
    <img src="/app/img/comRight.png" style="position: absolute; top: 0px; right: 0px; width: 95%; height: 140px;" /> 
    <div class="pkPlayer">
     <img src="/app/img/playerWin.png" class="background"  /> 
     <div class="title">
      　　　　　　
     </div> 
     <img src="" class="avatar" /> 
     <div class="score">
      --
     </div> 
     <div class="quitBack" style="display: none;"></div>
    </div> 
    <img src="/app/img/comLoser.png" class="pkLoser" style="display: none;" />
   </div> 
   <img src="/app/img/comE.gif" class="pkE" style="/* display: none; */" /> 
   <img src="/app/img/comV.png" class="pkV" style="/* display: none; */" /> 
   <img src="/app/img/comS.png" class="pkS" style="/* display: none; */" />
  </div>

  <div id="tishi" class="alert" style="display: none;"></div>   
  <div id="vaudioRoom" class="audioRoom" style="display: none;"></div> 
  <div id="vroomRule" class="createRoom" style="display: none;"></div>
  <div id='message' class="message" style="display: none;"></div> 

  <div class="myCardType" id="CardType">
   <div style="display: none;">
    高牌
   </div> 
  <!--  <div style="display: none;">
    对子
   </div> 
   <div style="display: none;">
    顺子
   </div> 
   <div style="display: none;">
    同花
   </div> 
   <div style="display: none;">
    同花顺
   </div> 
   <div style="display: none;">
    三条
   </div> -->
  </div> 



  <div id="table" class="table" style="width: 100%; height: 100%;">
   <img src="/app/img/table-zhajinhua.jpg" class="tableBack" /> 


   <div class="place" style="display: none; width: 99.0566px; height: 99.0566px; top: 191.038px;left: 0;
    right: 0;
    margin: auto;">
    <div class="totalScore">
     <div class="scores" id="totalScore">
      0
     </div> 
     <img src="/app/img/totalScore.png" />
    </div> 
   </div> 

   <div class="scoresArea"  style="display: none;"></div>
   <div class="cardDeal" >
    <div id='userfp'>
      <!--  <div class="card card11" ></div> 
       <div class="card card12" style="display: none;"></div> 
       <div class="card card13" style="display: none;"></div> 
       <div class="isSeen isSeen1" style="display: none;"></div> 
       <div class="isQuit isQuit1" style="display: none;"></div> 
       <div class="isLose isLose1" style="display: none;"></div> -->

    </div>
     
   
    <div class="myCards" style="display: none;"></div>
   </div> 

  <div id="member">
  </div>

   <div class="clock" style="display: none;" id='djs'>
     0
   </div>


    <div class="myButton"  id="Buttons">
  </div>



   <div class="pkBackground" style="display: none;"  onclick="qxbp();">
    <div class="pkBackText">
     选择比牌对象
    </div>
   </div>
  </div> 
 
  

 




 <script>
    function joinroom(){
      $("#valert").remove();
      token='{$token}';
      room='{$room.id}';
      var dkxx='{$room.dk}';
     load('show');
     if(dkxx){
      connect(dkxx);
    }
    else{
      load('hide');
      prompt('服务器没开启,请稍后再试');
      setTimeout("$('body').hide()",3000);
    }
    }
  </script>
<if condition="count($room['userlist']) egt 6 && $room['userlist'][$user['id']] neq 1">
<div id="valert2" class="alert">
   <div class="alertBack"></div> 
   <div class="mainPart" style="height: 31%;margin-top: -113.39px;">
    <div class="backImg">
     <div class="blackImg" style=" height: 59%;"></div>
    </div> 
    <div class="alertText" style="top: 35%;" id="tipmsg">房间人数已满</div> 
     <div class="buttonRight" style="left: 31.5%;width: 17vh;height: 5.5vh;" onclick="location.href='/'">
     返回首页
    </div>
     
   </div>
  </div>

  <php>
      exit();
  </php>
</if>
<if condition="(count($room['userlist']) gt 0 && $room['js'] eq 0) || ($room['js'] gt 0 && !$room['userlist'][$user['id']])">
  <div id="valert" class="alert">
   <div class="alertBack"></div> 
   <div class="mainPart" style="margin-top: -34vh;">
    <div class="backImg">
     <div class="blackImg" style=" height: 77%;"></div>
    </div> 
    <div class="id">
     <img src="/app/img/ID.png" /> 
     <div class="text">
       你的{$titlexx}ID:{$user.id} 
     </div>
    </div>
    <php>
      $count=M('user_room')->where(array('uid'=>$user['id'],'type'=>$room['type']))->count();
      $count=$count+0;
      $max=M('user_room')->where(array('uid'=>$user['id'],'type'=>$room['type']))->order('jifen desc')->find();
    </php> 
    <div class='lishijilu' style="">
    <div>历史最高分：<if condition="$max">{$max.jifen} ({$max.overtime|date="m-d H:i",###})<else/>暂无游戏记录</if></div>  
    <div>游戏总局数：{$count}</div> 
    </div>
    <div class="alertText" style="top: 1vh;">
     <div class="rull" style="font-size: 2.2vh;">
      
      <if condition="$room['gz2']">
        规则： 
      <a><foreach name="room['gz2']" item="one">{$one}</foreach></a> 
      <br />
      </if> 
      

      <if condition="$room['cm']">
      筹码： 
      <a>{$room['cm']}</a> 
      <br />
      </if> 


      <if condition="$room['sx']">
      上限： 
      <a>{$room['sx']}</a> 
      <br />
      </if> 
            
       局数： 
      <a>{$room['zjs']}局X{$room['fk']}房卡 </a> 

     </div> 
     <div style="margin-bottom: 9.5vh;
    position: relative;">
      房间中有<php>
          foreach($room['userlist'] as $key=>$one){
          if(!$indexxx)
          {
          $indexxx=1;
          }
          else{
          echo ',';
          }
          echo username($key);
          }
      </php>,是否加入？
     </div>
    </div> 
    
    <div style="position: relative;
    width: 100%;
    height: 5vh;
        top: -3vh;">
     <div class="buttonLeft" onclick="location.href='/'" style="    top: 0;
    bottom: 0;
    margin: auto;">
      创建房间
     </div> 
     <div class="buttonRight" onclick="joinroom()" style="   top: 0;
    bottom: 0;
    margin: auto;">
      加入游戏
     </div>
   </div>
  </div> 
</div>
<else/>
<script>
  joinroom();
</script>
</if> 
<audio onended="mp3playandpause('1miao');" id="1miao" src="/app/video/1miao.mp3"></audio>


<audio onended="mp3playandpause('message1');" id="message1" src="/app/message/message1.mp3"></audio>
<audio onended="mp3playandpause('message2');" id="message2" src="/app/message/message2.mp3"></audio>
<audio onended="mp3playandpause('message3');" id="message3" src="/app/message/message3.mp3"></audio>
<audio onended="mp3playandpause('message4');" id="message4" src="/app/message/message4.mp3"></audio>
<audio onended="mp3playandpause('message5');" id="message5" src="/app/message/message5.mp3"></audio>
<audio onended="mp3playandpause('message6');" id="message6" src="/app/message/message6.mp3"></audio>
<audio onended="mp3playandpause('message7');" id="message7" src="/app/message/message7.mp3"></audio>
<audio onended="mp3playandpause('message8');" id="message8" src="/app/message/message8.mp3"></audio>
<audio onended="mp3playandpause('message9');" id="message9" src="/app/message/message9.mp3"></audio>
<audio onended="mp3playandpause('message10');" id="message10" src="/app/message/message10.mp3"></audio>
<audio onended="mp3playandpause('message11');" id="message11" src="/app/message/message11.mp3"></audio>

<audio id="background" src="/app/video/back.mp3" ></audio>

<audio onended="mp3playandpause('2fen');" id="2fen" src="/app/video/2f.m4a"></audio>
<audio onended="mp3playandpause('4fen');" id="4fen" src="/app/video/4f.m4a"></audio>
<audio onended="mp3playandpause('5fen');" id="5fen" src="/app/video/5f.m4a"></audio>
<audio onended="mp3playandpause('8fen');" id="8fen" src="/app/video/8f.m4a"></audio>
<audio onended="mp3playandpause('10fen');" id="10fen" src="/app/video/10f.m4a"></audio>
<audio onended="mp3playandpause('16fen');" id="16fen" src="/app/video/16f.m4a"></audio>
<audio onended="mp3playandpause('20fen');" id="20fen" src="/app/video/20f.m4a"></audio>
<audio onended="mp3playandpause('40fen');" id="40fen" src="/app/video/40f.m4a"></audio>


<audio onended="mp3playandpause('kaipai');" id="kaipai" src="/app/video/audio2.m4a"></audio>

<audio onended="mp3playandpause('fapai');" id="fapai" src="/app/video/audio1.m4a"></audio>

<audio onended="mp3playandpause('shandian');" id="shandian" src="/app/video/com.m4a"></audio>

<audio onended="mp3playandpause('lookmp3');" id="lookmp3" src="/app/video/audio3.m4a"></audio>
<audio onended="mp3playandpause('menpai');" id="menpai" src="/app/video/audio4.m4a"></audio>

<audio onended="mp3playandpause('qipaimp3');" id="qipaimp3" src="/app/video/audio5.m4a "></audio>
<audio onended="mp3playandpause('losemp3');" id="losemp3" src="/app/video/lose.mp3"></audio>
<audio onended="mp3playandpause('winmp3');" id="winmp3" src="/app/video/win.mp3"></audio>
<script>
function over(msg){
  var html='<div id="valert2" class="alert">';
  html=html+'<div class="alertBack"></div> '; 
  html=html+'<div class="mainPart" style="height: 31%;margin-top: -113.39px;">'; 
  html=html+'<div class="backImg">'; 
  html=html+'<div class="blackImg" style="height: 59%;"></div>'; 
  html=html+'</div> '; 
  html=html+'<div class="alertText" style="top: 35%;" id="tipmsg">'+msg+'</div>'; 
  html=html+'<div class="buttonRight" style="left: 31.5%;width: 17vh;height: 5.5vh;" onclick="location.href='/'">返回首页</div> </div></div>'; 
  $('body').html(html);
}
var overscroll = function(el) {
  el.addEventListener('touchstart', function() {
    var top = el.scrollTop
      , totalScroll = el.scrollHeight
      , currentScroll = top + el.offsetHeight;
    //If we're at the top or the bottom of the containers
    //scroll, push up or down one pixel.
    //
    //this prevents the scroll from "passing through" to
    //the body.
    if(top === 0) {
      el.scrollTop = 1;
    } else if(currentScroll === totalScroll) {
      el.scrollTop = top - 1;
    }
  });
  el.addEventListener('touchmove', function(evt) {
    //if the content is actually scrollable, i.e. the content is long enough
    //that scrolling can occur
    if(el.offsetHeight < el.scrollHeight)
      evt._isScroller = true;
  });
}
document.body.addEventListener('touchmove', function(evt) {
  //In this case, the default behavior is scrolling the body, which
  //would result in an overflow.  Since we don't want that, we preventDefault.
  if(!evt._isScroller) {
    evt.preventDefault();
  }
});


var context = new (window.AudioContext || window.webkitAudioContext)();
var source = [];
var audioBuffer = [];

    function mp3play(id){
      if(id!='background' &&　mp3open==2){
        return false;
      }
        //document.getElementById(id).play();
        if(!audioBuffer[id]){
           loadAudioFile(id);
        }
        if(source[id]){
          source[id].stop()
        }
        source[id] = context.createBufferSource();
        source[id].buffer = audioBuffer[id];
        if(id=='background'){
            source[id].loop = true;
        }
        else{
          source[id].loop = false;
        }
        source[id].connect(context.destination);
        source[id].start(0); //立即播放
    }
    function mp3pause(id){
        //document.getElementById(id).pause();
        if (source[id]) {
          source[id].stop(); //立即停止
        }
    }

    function mp3playandpause(id){
        mp3play(id);
        mp3pause(id);
    }


function initSound(arrayBuffer,id) {
    context.decodeAudioData(arrayBuffer, function(buffer) { //解码成功时的回调函数
        audioBuffer[id] = buffer;
    }, function(e) { //解码出错时的回调函数
        console.log('Error decoding file', e);
    });
}


function loadAudioFile(id) {
    var url=$('#'+id).attr('src');
    var xhr = new XMLHttpRequest(); //通过XHR下载音频文件
    xhr.open('GET', url, true);
    xhr.responseType = 'arraybuffer';
    xhr.onload = function(e) { //下载完成
        initSound(this.response,id);
    };
    xhr.send();
}


    function audioAutoPlay(id){
        loadAudioFile(id);
    }
    function muiscready(){
          audioAutoPlay('message1');
          audioAutoPlay('message2');
          audioAutoPlay('message3');
          audioAutoPlay('message4');
          audioAutoPlay('message5');
          audioAutoPlay('message6');
          audioAutoPlay('message7');
          audioAutoPlay('message8');
          audioAutoPlay('message9');
          audioAutoPlay('message10');
          audioAutoPlay('message11');
          audioAutoPlay('background');


          audioAutoPlay('2fen');
          audioAutoPlay('4fen');
          audioAutoPlay('5fen');
          audioAutoPlay('8fen');
          audioAutoPlay('10fen');
          audioAutoPlay('16fen');
          audioAutoPlay('20fen');
          audioAutoPlay('40fen');
          audioAutoPlay('kaipai');
          audioAutoPlay('fapai');
          audioAutoPlay('shandian');
          audioAutoPlay('lookmp3');
          audioAutoPlay('menpai');
          audioAutoPlay('qipaimp3');
          audioAutoPlay('losemp3');
          audioAutoPlay('winmp3');

           if(bgmp3open==1){
          setTimeout(function(){
              mp3pause('background');
              mp3play('background');
          },2000)
          }
           if(bgmp3open==2){
               mp3pause('background');
            }

    }
function onBridgeReady(){
 WeixinJSBridge.invoke('getNetworkType',{},
    function(e){
        //WeixinJSBridge.log(e.err_msg);
         mp3play('1miao');  
      });
}

if (typeof WeixinJSBridge == "undefined"){
    if( document.addEventListener ){
        document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
    }else if (document.attachEvent){
        document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
        document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
    }
}else{
    onBridgeReady();
}


muiscready();
</script>
 </body>
</html>